gamevar temp 0 2
gamevar camera_exist -1 1
gamevar camera_x 0 1
gamevar camera_y 0 1
gamevar camera_z 0 1
gamevar camera_horiz 0 1
gamevar camera_sect 0 1

onevent EVENT_DISPLAYREST    
ifvarn camera_exist -1        // we shouldn't display if there's no existing camera actor        
showviewunbiased camera_x camera_y camera_z camera_ang camera_horiz camera_sect 16 41 56 69
endevent

onevent EVENT_GAME    
getactor[THISACTOR].picnum temp    
ifvare temp PIGCOP    {  getactor[THISACTOR].pal temp        
ifvarvare camera_exist THISACTOR ifvarn temp 200 // if the pal is altered somehow we can remove it as the camera            
setvar camera_exist -1        
else ifvare temp 200        {  getactor[THISACTOR].x camera_x            
getactor[THISACTOR].y camera_y            
getactor[THISACTOR].z camera_z            
subvar camera_z 8192 // offset until you get to eye level            
getactor[THISACTOR].ang camera_ang            
getactor[THISACTOR].sectnum camera_sect            
setvar camera_horiz 100            
setvarvar camera_exist THISACTOR  }    }
endevent